package com.jh.rq;

import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * @author Li
 * @Date 2023/4/20 14:27
 */
public class TreeMapDemo2 {
    public static void main(String[] args) {
        TreeMap<Student,String> treeMap =  new TreeMap<>();
        Student stu1 = new Student("小明",20);
        Student stu2 = new Student("小兵",26);
        Student stu3 = new Student("小红",22);
        Student stu4 = new Student("小刚",30);

       treeMap.put(stu1,"广州");
       treeMap.put(stu2,"南京");
       treeMap.put(stu3,"杭州");
       treeMap.put(stu4,"成都");

       treeMap.forEach(new BiConsumer<Student, String>() {
           @Override
           public void accept(Student key, String s) {
               System.out.println(key+"---"+s);
           }
       });
    }

}
